package com.hl.sfzy.service.wxwappService;

import com.github.pagehelper.PageHelper;
import com.hl.sfzy.entity.wxwapp.ArticleDetail;
import com.hl.sfzy.entity.wxwapp.CourseOnline;
import com.hl.sfzy.entity.wxwapp.TeacherDetail;
import com.hl.sfzy.mapper.wxwappMapper.TeacherDetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @className: TeacherDetailService
 * @author: WXW
 * @date: 2024/9/7 11:13
 * @Version: 1.0
 * @description:
 */
@Service
public class TeacherDetailService {
    @Autowired
    private TeacherDetailMapper teacherDetailMapper;

    public TeacherDetail findAllHave(Integer id, Integer pageNum, Integer pageSize) {
        long l = (long) id;
        TeacherDetail teacherDetail = teacherDetailMapper.selectAllHaveDetail(l);
        //实现分页
        PageHelper.startPage(pageNum, pageSize);
        List<ArticleDetail> details = teacherDetailMapper.selectArticles(l);
        PageHelper.startPage(pageNum, pageSize);
        List<CourseOnline> courseOnlines = teacherDetailMapper.selectCourses(l);
        //将查询到的数据放入teacherDetail中
        teacherDetail.setArticleDetails(details);
        teacherDetail.setCourseOnlines(courseOnlines);
        return teacherDetail;

    }

}
